package com.vdongchina.thread.executor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池的处理
 */
public class ThreadPoolExecutor {


    public static void main(String[] args) {
        fixedThreadPoolTest();
    }


    /**
     * FixedThreadPool 中使用的是无界队列,maximumPoolSize将是一个无效参数,将会造成内存溢出
     */
    private static void fixedThreadPoolTest() {
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(3);
        try {
            fixedThreadPool.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程池执行!");
                }
            });

        } catch (Exception e) {

        } finally {
            fixedThreadPool.shutdown(); //一定要执行,否则容易造成内存溢出
        }
    }


}
